<?php
namespace app\restaurant\model;

use app\BaseModel;
use think\facade\Db;

class Cate extends BaseModel
{
    //定义表名
    protected $name = 'longbing_card_restaurant_cate';



    /**
     * @author chenniang
     * @DataTime: 2020-09-29 11:04
     * @功能说明:分类添加
     */
    public function cateAdd($data){

        $data['create_time'] = time();

        $data['update_time'] = time();

        $res = $this->insert($data);

        return $res;

    }



    /**
     * @author chenniang
     * @DataTime: 2020-09-29 11:05
     * @功能说明:分类编辑
     */
    public function cateUpdate($dis,$data){

        $data['update_time'] = time();

        $res = $this->where($dis)->update($data);

        return $res;

    }


    /**
     * @author chenniang
     * @DataTime: 2020-09-29 11:06
     * @功能说明:列表
     */
    public function cateList($dis,$page){

        $data = $this->where($dis)->order('top desc,id desc')->paginate($page)->toArray();

        return $data;

    }


    /**
     * @author chenniang
     * @DataTime: 2020-09-29 11:43
     * @功能说明:
     */
    public function cateInfo($dis){

        $data = $this->where($dis)->find();

        return !empty($data)?$data->toArray():[];

    }












}